﻿<UserControl x:Class="Big3.Hitbase.CatalogView.CatalogTreeView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Big3.Hitbase.CatalogView"
    Height="300" Width="300">
    <UserControl.Resources>
        <Style x:Key="TreeViewItemStyle"
               TargetType="{x:Type TreeViewItem}">
            <Setter Property="IsSelected"
                        Value="{Binding IsSelected, Mode=TwoWay}" />
            <Setter Property="IsExpanded"
                        Value="{Binding IsExpanded, Mode=TwoWay}" />
        </Style>
        
        <local:CDItemDataTemplateSelector x:Key="CDItemSelector" />
        
        <DataTemplate x:Key="TrackTemplate">
            <StackPanel Orientation="Horizontal" MouseRightButtonDown="newItem_MouseRightButtonDown">
                <Image Height="15" Source="{Binding Image}" Margin="0,0,5,0" />
                <TextBlock Text="{Binding Title}" VerticalAlignment="Center"  />
            </StackPanel>
        </DataTemplate>

        <HierarchicalDataTemplate x:Key="CDTemplate"
            ItemsSource="{Binding Tracks}"
            ItemTemplate="{StaticResource TrackTemplate}">
            <StackPanel Orientation="Horizontal" MouseRightButtonDown="newItem_MouseRightButtonDown">
                <Image Height="15" Source="{Binding Image}" Margin="0,0,5,0" />
                <TextBlock Text="{Binding Title}" VerticalAlignment="Center"  />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate x:Key="CDSetTemplate"
            ItemsSource="{Binding CDs}"
            ItemTemplate="{StaticResource CDTemplate}">
            <StackPanel Orientation="Horizontal" MouseRightButtonDown="newItem_MouseRightButtonDown">
                <Image Height="15" Source="{Binding Image}" Margin="0,0,5,0" />
                <TextBlock Text="{Binding Title}" VerticalAlignment="Center"  />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate x:Key="ArtistTemplate"
            ItemsSource="{Binding Items}" 
            ItemTemplateSelector="{StaticResource CDItemSelector}" >
            <StackPanel Orientation="Horizontal" MouseRightButtonDown="newItem_MouseRightButtonDown">
                <Image Height="15" Source="{Binding Image}" Margin="0,0,5,0" />
                <TextBlock Text="{Binding Artist}" VerticalAlignment="Center" />
            </StackPanel>
        </HierarchicalDataTemplate>
        
        <!-- Wait Indicator -->
        <Color x:Key="FilledColor" A="255" B="155" R="155" G="155"/>
        <Color x:Key="UnfilledColor" A="0" B="155" R="155" G="155"/>
        <Storyboard x:Key="Animation0" FillBehavior="Stop" BeginTime="00:00:00.0" RepeatBehavior="Forever">
            <ColorAnimationUsingKeyFrames Storyboard.TargetName="_00" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                <SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
                <SplineColorKeyFrame KeyTime="00:00:00.8" Value="{StaticResource UnfilledColor}"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Animation1" BeginTime="00:00:00.1" RepeatBehavior="Forever">
            <ColorAnimationUsingKeyFrames Storyboard.TargetName="_01" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                <SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
                <SplineColorKeyFrame KeyTime="00:00:00.8" Value="{StaticResource UnfilledColor}"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Animation2" BeginTime="00:00:00.2" RepeatBehavior="Forever">
            <ColorAnimationUsingKeyFrames Storyboard.TargetName="_02" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                <SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
                <SplineColorKeyFrame KeyTime="00:00:00.8" Value="{StaticResource UnfilledColor}"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Animation3" BeginTime="00:00:00.3" RepeatBehavior="Forever">
            <ColorAnimationUsingKeyFrames Storyboard.TargetName="_03" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                <SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
                <SplineColorKeyFrame KeyTime="00:00:00.8" Value="{StaticResource UnfilledColor}"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Animation4" BeginTime="00:00:00.4" RepeatBehavior="Forever">
            <ColorAnimationUsingKeyFrames Storyboard.TargetName="_04" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                <SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
                <SplineColorKeyFrame KeyTime="00:00:00.8" Value="{StaticResource UnfilledColor}"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Animation5" BeginTime="00:00:00.5" RepeatBehavior="Forever">
            <ColorAnimationUsingKeyFrames Storyboard.TargetName="_05" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                <SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
                <SplineColorKeyFrame KeyTime="00:00:00.8" Value="{StaticResource UnfilledColor}"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Animation6" BeginTime="00:00:00.6" RepeatBehavior="Forever">
            <ColorAnimationUsingKeyFrames Storyboard.TargetName="_06" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                <SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
                <SplineColorKeyFrame KeyTime="00:00:00.8" Value="{StaticResource UnfilledColor}"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Animation7" BeginTime="00:00:00.7" RepeatBehavior="Forever">
            <ColorAnimationUsingKeyFrames Storyboard.TargetName="_07" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                <SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
                <SplineColorKeyFrame KeyTime="00:00:00.8" Value="{StaticResource UnfilledColor}"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>

    </UserControl.Resources>
    <UserControl.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource Animation0}"/>
            <BeginStoryboard Storyboard="{StaticResource Animation1}"/>
            <BeginStoryboard Storyboard="{StaticResource Animation2}"/>
            <BeginStoryboard Storyboard="{StaticResource Animation3}"/>
            <BeginStoryboard Storyboard="{StaticResource Animation4}"/>
            <BeginStoryboard Storyboard="{StaticResource Animation5}"/>
            <BeginStoryboard Storyboard="{StaticResource Animation6}"/>
            <BeginStoryboard Storyboard="{StaticResource Animation7}"/>
        </EventTrigger>
    </UserControl.Triggers>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Name="TreeViewWidth" Width="*" />
            <ColumnDefinition Width="Auto" MinWidth="4" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <TreeView Grid.Column="0" Name="TreeView" ContextMenuOpening="TreeView_ContextMenuOpening" 
                  ItemContainerStyle="{StaticResource TreeViewItemStyle}" 
                  ItemTemplate="{StaticResource ArtistTemplate}"  SelectedItemChanged="TreeView_SelectedItemChanged"
              Keyboard.PreviewKeyDown="TreeView_PreviewKeyDown" TreeViewItem.Expanded="TreeView_Expanded"
                  VirtualizingStackPanel.IsVirtualizing="True" PreviewTextInput="TreeView_PreviewTextInput"> 
        </TreeView>
        <GridSplitter Grid.Column="1" ResizeBehavior="PreviousAndNext" Width="4" VerticalAlignment="Stretch" />
        <WindowsFormsHost  Grid.Column="2" Name="FormCDElementHost" />
        <!-- Wait indicator -->
        <Grid Grid.Column="0" Name="GridLoadingCircle" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <Canvas Grid.Row="0" Canvas.Left="21.75" Canvas.Top="14" Height="91.302" Width="102.197" >
                <Canvas.Resources>
                    <Style TargetType="Ellipse">
                        <Setter Property="Width" Value="15"/>
                        <Setter Property="Height" Value="15" />
                        <Setter Property="Fill" Value="#00FFFFFF" />
                    </Style>
                </Canvas.Resources>
                <Ellipse x:Name="_00" Canvas.Left="24.75" Canvas.Top="50"/>
                <Ellipse x:Name="_01" Canvas.Top="36" Canvas.Left="29.5"/>
                <Ellipse x:Name="_02" Canvas.Left="43.5" Canvas.Top="29.75"/>
                <Ellipse x:Name="_03" Canvas.Left="57.75" Canvas.Top="35.75"/>
                <Ellipse x:Name="_04" Canvas.Left="63.5" Canvas.Top="49.75" />
                <Ellipse x:Name="_05" Canvas.Left="57.75" Canvas.Top="63.5"/>
                <Ellipse x:Name="_06" Canvas.Left="43.75" Canvas.Top="68.75"/>
                <Ellipse x:Name="_07" Canvas.Top="63.25" Canvas.Left="30" />
                <Ellipse Stroke="{x:Null}" Width="39.5" Height="39.5" Canvas.Left="31.75" Canvas.Top="37" Fill="{x:Null}"/>
            </Canvas>
            <TextBlock Grid.Row="1" Text="Wird geladen..." FontSize="20" Foreground="Black" />
        </Grid>
    </Grid>
</UserControl>
